﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<t_205_verk_hopur_12.Models.ChannelVideoViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Sarpurinn
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<% if (Model.Video.ElementAtOrDefault(0) == null)
   { %>
    <h2>Engin myndbönd</h2>
    <p>
        <%= Html.ActionLink("Skrá nýtt myndband", "AddVideo", new { id = Model.Channel.ID })%>
    </p>
    <%}
   else
   { %>
    <h2>Myndbönd</h2>
    
    <p>
        <%= Html.ActionLink("Skrá nýtt myndband", "AddVideo", new { id = Model.Channel.ID })%>
    </p>

    <table id="search">
        <tr>
            <th>
                Aðgerðir
            </th>
            <th>
                Titill
            </th>
            <th>
                Lýsing
            </th>
            <th>
                Stigafjöldi
            </th>
            <th>
                Staða
            </th>
        </tr>

    <% foreach (var item in Model.Video)
       { %>
    
        <tr>
            <td>
                <%= Html.ActionLink("Nánar", "VideoDetails", new { id = item.ChannelID, videoID = item.ID }, null)%> |
                
                <% if (Model.Channel.Autocracy == true)
                   {%>
                        <% if (Model.isOwner)
                           { %>
                                <%= Html.ActionLink("Breyta", "EditVideo", new { channelID = item.ChannelID, videoID = item.ID }, null)%> |
                                <% if (item.State != 1)
                                     { %>
                                         <%= Html.ActionLink("Eyða", "DeleteVideo", new { id = item.ChannelID, videoID = item.ID }, null)%> |
                                  <% } %>
                         <%} %>
                           <% if (Model.isOwner)
                           { %>
                           <% if (item.State != 1)
                              {%>              
                                    <%= Html.ActionLink("Setja í kosningu", "ElectionCreate", new { id = item.ChannelID, videoID = item.ID }, null)%>
                           <% } %>
                           <% else
                              {%>
                                    <%= Html.ActionLink("Enda kosningu", "ElectionEnd", new { id = item.ChannelID, videoID = item.ID }, null)%>
                           <% } %>
                        <% } %>
                <% } %>
                
                <% if (Model.Channel.Autocracy == false)
                   { %>
                        <% if (Model.isOwner)
                           { %>
                               <%= Html.ActionLink("Eyða", "DeleteVideo", new { id = item.ChannelID, videoID = item.ID }, null)%> |
                               <% if (item.State == 0 || item.State == 1)
                                  { %>
                                        <%= Html.ActionLink("Samþykkja", "ConfirmVideo", new { id = item.ChannelID, videoID = item.ID }, null)%>
                               <% } %> 
                        <% } %>
                        
                 <%} %>
            </td>
            <td>
                <%= Html.Encode(item.Title)%>
            </td>
            <td>
                <%= Html.Encode(item.Description)%>
            </td>
            <td class ="rating">
                <%= Html.Encode(item.Rating)%>
            </td>
            <td class ="rating">
                <% if(item.State == 0){
                    %>
                       <%= Html.Encode("Nýtt")%>
                    <%
                    }else if(item.State == 1){
                     %>
                       <%= Html.Encode("Í kosningu")%>
                    <%
                    }else if(item.State == 2){
                    %>
                       <%= Html.Encode("Samþykkt")%>
                    <%
                    }else if(item.State == 3){
                     %>
                       <%= Html.Encode("Hafnað")%>
                    <%
                    } else {
                    %>
                       <%= Html.Encode("Birt")%>
                    <%
                    }
                %> 
            </td>
        </tr>
    
    <% } %>

    </table>
    <% } %>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="LogoText" runat="server">
    <%= Html.ActionLink(Model.Channel.Name, "Index", new { id = Model.Channel.ID }) %>

</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="MenuBar" runat="server">
    <% Html.RenderPartial("AdminChannelMenuBar", Model.Channel); %>
</asp:Content>

